<?php
/**
*
* Show the products in a category
*
* @package	com.promobico.mvm
* @subpackage 
* @author Zbigniew Mazur
* @link http://www.promobico.com
* @copyright Copyright (c) 2004 - 2010 Promobico Limited. All rights reserved.
* 
* @version $Id:  $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

{ 	"cart_url" : <?php echo json_encode(JURI::root() . 'index.php?option=com_mvm&task=cart.cart&view=cart&format=json'); ?>,

	"subcategories" : [
	<?php 
	$uriPrefix = JMvmuri::prefix();
	if ($this->category->haschildren) {
		$cat_count = sizeof($this->category->children);
		for ($i=0; $i < $cat_count; $i++) {
			$category = $this->category->children[$i];
	?>
	
		{
			"name" : <?php echo json_encode($category->category_name); ?>,
			"id" : <?php echo json_encode($category->category_id); ?>,
			"url" : <?php echo json_encode( $uriPrefix . JRoute::_( 'index.php?option=com_mvm&view=category&format=json&category_id='.$category->category_id)); ?>,
			"image_filename" : <?php echo json_encode( $category->category_full_image);?>,
			"image_filename_thumb" : <?php echo json_encode($category->category_thumb_image);?>,
			"image_url" : <?php echo json_encode( JURI::root().IMAGEURL.'category/'. $category->category_full_image);?>,
			"image_url_thumb" : <?php echo json_encode(JURI::root().IMAGEURL.'category/'.$category->category_thumb_image);?>,
			"num_of_prod" : <?php echo json_encode ($category->number_of_products); ?>
			
			
			}<?php if ($i < ($cat_count-1) ) echo ",";// object separator 	
		}
	}	
	?>

	] // subcategories
	,
	"products" : [
<?php 
	$prod_count = sizeof($this->products);
	for ($i=0; $i < $prod_count; $i++) { 
		$product = $this->products[$i];
?>

		{
			"name" : <?php echo json_encode($product->product_name);?>,
			"id" : <?php echo json_encode($product->product_id);?>,
			"url" : <?php echo json_encode( $uriPrefix . JRoute::_( 'index.php?option=com_mvm&view=product&format=json&product_id='.$product->product_id)); ?>,
			"image_filename" : "<?php echo ( $product->product_full_image);?>",
			"image_filename_thumb" : "<?php echo ($product->product_thumb_image);?>",
			"image_url_thumb" : <?php echo json_encode(JURI::root().IMAGEURL.'product/'.$product->product_thumb_image); ?>,
			"image_url" : <?php echo json_encode( JURI::root().IMAGEURL.'product/'.$product->product_full_image);?>,
			"desc" : <?php echo json_encode($product->product_s_desc); ?>			
			
<?php if (_SHOW_PRICES == '1') {?> , 
			'salesPrice' : <?php echo json_encode($product->prices['salesPrice']); ?>,
			'basePrice' : <?php echo json_encode($product->prices['basePrice']); ?>,
			'basePriceVariant' : <?php echo json_encode($product->prices['basePriceVariant']); ?>,
			'basePriceWithTax' : <?php echo json_encode($product->prices['basePriceWithTax']); ?>,
			'discountedPriceWithoutTax' : <?php echo json_encode($product->prices['discountedPriceWithoutTax']); ?>,
			'priceBeforeTax' : <?php echo json_encode($product->prices['priceBeforeTax']); ?>,
			'taxAmount' : <?php echo json_encode($product->prices['taxAmount']); ?>,
			'discountAmount' : <?php echo json_encode($product->prices['discountAmount']); ?>,
			'priceWithoutTax' : <?php echo json_encode($product->prices['priceWithoutTax']); ?>,
			'subtotal' : <?php echo json_encode($product->prices['subtotal']); ?>,
			'subtotal_tax_amount' : <?php echo json_encode($product->prices['subtotal_tax_amount']); ?>,
			'subtotal_discount' : <?php echo json_encode($product->prices['subtotal_discount']); ?>,
			'sobtotal_with_tax' : <?php echo json_encode($product->prices['subtotal_with_tax']); ?>,
		    'currency': <?php echo json_encode($product->prices['vendorCurrency'])?>,
			'add_one_to_basket_url' : <?php echo json_encode(JURI::root().'?option=com_mvm&task=cart.add&view=cart&quantity=1&format=json&product_id='. $product->product_id);?>
<?php 
}//.... if 
?>
		}<?php if ($i < ($prod_count-1) ) echo ",";// object separator 
?>

<?php
} 
?>
	] // products
}// virtuemart 
	